int s[100][100],c[100];main(w,h,b,l,i,j){for(scanf("%d%d\n",&w,&h),gets(&b);~scanf("%d%d",&b,&l);)for(j=b?0:l;j<h;j++)for(i=b?l:0;i<w;i++)s[i][j]++;for(j=0;j<h;j++)for(i=0;i<w;i++)c[s[i][j]]++;for(i=j=0;i<100;j=c[i]>j?c[i]:j,i++);printf("%d\n",j);}
